1. Field of the Invention
This apparatus and method relates to sending and receiving data over a Universal Serial Bus network and, in particular, to sending and receiving data to and from multiple endpoint pipes.
2. Description of the Related Art
Universal Serial Bus (USB) is a standard peripheral interface for attaching personal computers to a wide variety of devices: e.g., digital telephone lines, monitors, modems, mice, printers, scanners, game controllers, keyboards, and other peripherals. A USB thus replaces existing interfaces such as the RS-232C serial ports, parallel ports, PS/2 interface and game/MIDI ports.
In accordance with USB, all attached devices connect to a personal computer through a single connector type using a tiered-star topology. A host personal computer includes a single USB controller. The host controller provides the interface between the USB network and the host personal computer. The host controller controls all accesses to USB resources and monitors the bus's topology. A USB hub provides USB attachment points for USB devices.
An example of the tiered-star topology of a USB network is shown in FIG. 1. Host PC 100 is a typical personal computer having a USB port connection via host controller 102. Host controller 102 connects directly to root hub 110, which is typically implemented as part of the Host PC 100. Compound device 120, hub 130, and device 140 connect to the host controller 102 through hub 110. Devices 132 and 134 connect to the host controller 102 through hub 130 and through hub 110.
Compound device 120 includes devices 124, 126 and hub 122. Hub 122 of compound device 120 connects to the host controller through hub 110. Devices 124 and 126 of compound device 120 connect to the host controller 102 through hub 122 and through hub 110. A practical example of a compound device would be an integrated printer and fax. The printer could be device 124, and the fax could be device 126.
The tiered-star topography illustrated in FIG. 1 allows data to be transmitted into and out of the host PC 100 to the various devices. When data is transmitted from the host to a device it is transmitted downstream through the interconnecting hubs. When data is transmitted from a device to the host it is transmitted upstream through the interconnecting hubs.
The USB hubs and devices may be connected and disconnected without completely re-starting the USB network. Upon connection of a device or hub to an upstream hub the upstream hub will notify the host controller of a change in status. Following USB protocol, the host controller will enable the port of the hub to which the device is connected. The host controller will then assign a unique functional address to each device. Ports are enabled one at a time as the host controller 102 assigns unique functional addresses. Upon connection of a compound device, the host controller assigns a unique functional address to each device contained within the compound device.
Returning to FIG. 1, devices 124, 126, 132, 134, and 140 will each be assigned a unique functional address upon connection to the USB network. Likewise, hubs 110, 122, and 130 will each be assigned a unique functional addresses and act as USB devices upon connection to the USB network.
A USB Function is a USB device that is able to transmit and receive information on the bus. A Function may have one, or more, configurations, each of which defines the interfaces which make up the device. Each interface, in turn, is made up of one of more endpoints.
An endpoint is the ultimate source, or sink, of data. An endpoint pipe provides for the movement of data between the USB and memory, and completes the path between the USB Host and the function endpoint. A USB device may support up to 16 such endpoint pipes at any given time. Each endpoint pipe will have the same functional address.
At initialization of an endpoint device, the host controller associates a pipe with the endpoint functions. The pipes allow the host controller to move data into and out of a host memory buffer to and from the endpoints. The USB specification implements two types of pipe communication modes: stream and message. Stream data does not have a defined USB structure. Message data does have a defined USB structure.
At initialization, a pipe is assigned a claim on USB bus access and bandwidth usage. This assignment will determine priority for transmitting data over a particular pipe to an endpoint. The endpoint's characteristics are also associated with the pipe at initialization. Such characteristics include maximum data payload sizes, directionality of transfers, and other appropriate characteristic data. These characteristics are used by the host in making data transfers over the pipe.
The assignment of a claim on USB bus access and bandwidth to a pipe allows the host controller to make a best effort to ensure that all input/output data requests to endpoints will be adequately serviced over the available bandwidth of the USB bus. The assignment of claims to bus access and bandwidth to a pipe limits the allocation to later configured devices. Once the bandwidth of a USB bus is completely allocated, subsequently configured devices cannot be allocated bus bandwidth. Consequently the subsequently configured devices cannot be allocated pipes.
Some time after the initialization process completes, the allocation of pipes to particular endpoints of a device is fixed. This can be changed as the requested functionality of the device evolves. Accordingly, devices which include a plurality of endpoint functions will be assigned a plurality of pipes (each associated with a particular endpoint).
Each endpoint is an addressable entity on the USB and is required to respond to IN and OUT tokens from the USB host controller. The IN tokens indicate that the host has requested to receive information from an endpoint, and OUT tokens indicate that the host is about to send information to an endpoint.
On detection of an IN token addressed to an endpoint, the endpoint is responsible for responding with a data packet. If the endpoint is currently stalled, a STALL handshake packet is returned. If the endpoint is enabled, but no data is present, a NAK (Negative Acknowledgement) handshake packet is sent.
Similarly, on detection of an OUT token addressed to an endpoint, the endpoint is responsible for receiving a data packet sent by the host and storing it in a buffer. If the endpoint pipe is currently stalled, at the end of data transmission, a STALL handshake packet is sent. If the endpoint pipe is currently disabled, at the end of the data transmission, no handshake packet is sent. If the endpoint pipe is enabled, but no buffer is present in which to store the data, a NAK (Negative Acknowledgement) handshake packet is sent.
A disabled endpoint, or endpoints not currently mapped to an endpoint pipe do not respond to IN, OUT, or SETUP tokens.
The USB defines four types of data transfers over a pipe: control, bulk, interrupt, and isochronous.
Control transfers are used by the host to configure a device upon attachment to a hub. Control transfers may also be used by the host controller for implementation specific transactions with a device.
Bulk transfers are sequential transfers generally of large amounts of data. Bulk transfers provide reliable transactions by use of error detection and resending corrupted data. The bus bandwidth allocated for a bulk transfer can be whatever is currently available as bulk transfers are not time sensitive.
Interrupt transfers are small spontaneous data transactions emanating from a device.
Isochronous transfers are continuous, real-time data transactions. Isochronous transfers are allocated a dedicated portion of a USB network's bandwidth to ensure timely completion of isochronous transactions.
Although a device may include a plurality of endpoint functions, those endpoint functions may not necessarily operate simultaneously. By way of example, a multi-function device may include a fax and a digital telephone function. During initialization, the multi-function device is assigned a unique functional address and the fax and digital telephone functions are each associated with distinct endpoint numbers. Out pipes for transmitting data to each function are likewise allocated during initialization. One Out pipe is associated with an endpoint number for the fax function, and one Out pipe is associated with an endpoint number for the printer function. A fax and digital telephone will each typically require an isochronous Out pipe because their transactions should operate in real time.
During operation of the multi-function device, the host controller will access only one of the functions at a time. Consequently only one of the Out pipes allocated for the fax and digital telephone functions will be used at any given time.
Where a plurality of devices are connected to a USB bus, the bandwidth resources may not meet the demands of all the devices. Consequently, the assignment of a claim to bus access and bandwidth to both of the fax's out pipe and the digital telephone's out pipe can limit the allocation of resources to subsequently configured devices. This limitation affects subsequent allocations even thought the fax and the digital telephone will not be used simultaneously.
One way to avoid this problem is to configure a device to have a particular personality then, when another personality is required, to reset the device and configure it to have a different personality. For example a multi-function fax and printer device could first be configured to operate as a fax. Later, should the host PC require a printer, the host PC could reset the device to reconfigure the multi-function device to act as a printer. Thus, by resetting a multi-function device, the device can be caused have multiple personalities. The resetting of a multi-function device, however, requires a control transfer to effectuate each personality change.
Alternatively, multiple interfaces can share an endpoint. This may be accomplished by providing an additional layer of software. The USB Fearure Specification describes such an arrangement for sharing an endpoint across multiple interfaces. This arrangement, however, requires software multiplexing, additional fields for endpoint descriptors, and a flow control mechanism.